<template>
	<view class="page">
			<!-- <view class="searchRow" v-if="isTeacher==1">
				<view class="leftBox">
					<view class="row" >
						<view class="label">
							{{language.leaveRecord.name}}:
						</view>
						<view class="val">
							<u-input v-model="params.name" :placeholder="language.leaveRecord.namePlaceholder"></u-input>
						</view>
					</view>
				</view>
				<view class="btn" @click="goSearch">
					{{language.leaveRecord.searchBtn}}
				</view>
			</view> -->
			<u-subsection :list="selectList" :current="current"  @change="sectionChange"></u-subsection>
			<scrollYBox styleText="height: calc( 100vh - 0rpx ) ;" @scrolltolower="scrolltolower" :list="list">
						<template>
							<view style="padding-bottom: 50rpx;">
								<view class="boxItem" v-for="(item,index) in list" :key="index">
									<view class="row flex">
										<view class="item ">
											<view class="label">
												{{'主题：'}}
											</view>
											<view class="val">
												{{item.themeName }}
											</view>
										</view>
									</view>
									<view class="row flex">
										<view class="item ">
											<view class="label">
												{{'有效时间：'}}
											</view>
											<view class="val">
												{{item.beginDate+' - '+item.endDate}}
											</view>
										</view>
									</view>
									<view class="row flex">
										<view class="item ">
											<view class="label">
												{{'科目：'}}
											</view>
											<view class="val">
												{{item.courseName ? item.courseName : ''}}
											</view>
										</view>
										<view class="item " v-if="item.nusubStatus==1">
											<view class="label">
												{{'状态：'}}
											</view>
											<view class="val">
												{{'待审核'}}
											</view>
										</view>
										<view class="btn" style="background: #f5bd00;" v-if="!current&&item.nusubStatus==0" @click="handleCancel(item)">
											{{'申请退课'}}
										</view>
									</view>
								</view>
							</view>
						</template>
					</scrollYBox>
					<u-modal :show="showCancel"  title="退课" showConfirmButton showCancelButton @cancel="showCancel=false" @confirm="cancelConfirm" >
						<!-- <view class="slot-content">
							<view class="" style="width: 600rpx;">
								<uni-datetime-picker type="date" style="width: 360rpx;"  v-model="cancelDate" placeholder="请选择" />
							</view>
							
						</view> -->
					</u-modal>
	</view>
</template>

<script>
	import { queryPageDateilListApi,csPurchaseCourseOrderApplyForUnsubApi} from '@/common/api/commonApi/bugClass.js'
	export default {
		data() {
			return {
				list:[],
				params:{
					pageNo:1,
					pageSize: 10,
				},
				assessDate_begin: Number(new Date()),
				assessDate_end: Number(new Date()),
				assessDate_beginShow : false,
				assessDate_endShow : false,
				total : 0,
				isTeacher: uni.getStorageSync('isTeacher') ? uni.getStorageSync('isTeacher') : 2,
				auditObj:{},
				auditShow: false,
				auditList: [{
						name: '是',
						value: 1
					},
					{
						name: '否',
						value: 2,
					},
				],
				auditValue: 1,
				auditOpinion:'',
				selectList:[
					'未退订',
					'已退订',
				],
				cancelObj : {},
				showCancel : false,
				current:0,
				cancelDate:'',
				
			}
		},
		components:{
		},
		methods: {
			cancelConfirm(){
				csPurchaseCourseOrderApplyForUnsubApi({
					id: this.cancelObj.id
					//beginRundDate : this.cancelDate,
				}).then(res=>{
					this.setMessage('操作成功')
					this.showCancel = false
					setTimeout(()=>{
						this.goSearch()
					},500)
				})
			},
			sectionChange(index){
				this.current = index
				this.goSearch()
			},
			handleCancel(item){
				this.cancelObj = item
				this.showCancel = false
			},
			scrolltolower(){
				if(this.total == this.list.length){
					return this.setMessage('没有更多了')
				}
				this.params.pageNo ++
				this.getList()
			},
			getList(){
				let params = this.params
				// if(!params.assessDate_end) delete params.assessDate_end
				// if(!params.assessDate_begin) delete params.assessDate_begin
				// if(this.isTeacher==1)
				 params.nusubStatus = this.current==0 ? '9' : '2'
				return queryPageDateilListApi(params).then(res=>{
					if(params.pageNo==1) this.list = []
					res.result.records.forEach(item=>{
						item.beginDate = item.beginDate.split(' ')[0]
						item.endDate = item.endDate.split(' ')[0]
					})
					this.list = this.list.concat(res.result.records)
					this.total = res.result.total
				})
			},
			goSearch(){
				this.params.pageNo = 1
				
					this.getList()
			
			}
			
		},
		onLoad() {
			this.getList()
		},
		onShow() {
			// this.goSearch()
		},
	}
</script>

<style lang="scss" scoped>
	.searchRow{
			background-color: #fff;
			display: flex;
			align-items: center;
			padding: 0rpx 20rpx 0 20rpx;
			border-bottom: 2rpx solid #dedede;
			height: 140rpx;
			margin: 20rpx;
			.leftBox{
				flex: 1;
				.row{
					display: flex;
					align-items: center;
					height: 70rpx;
					padding-left: 20rpx;
					.label{
						color: #000000d9;
						margin-right: 30rpx;
					}
					.val{
						color: #595959;
					}
				}
			}
			.btn{
				width: 140rpx;
				height: 56rpx;
				border-radius: 10rpx;
				color: #fff;
				@include flexCenter;
				background-color: #4089f0;
			}
			
	}
	
	
.page{
	background-color: #f1f1f1;
	// height: 100vh;
	.searchBox{
		display: flex;
		align-items: center;
		background-color: #fff;
		padding: 0 20rpx;
		border-bottom: 1px solid #f1f1f1;
		margin: 20rpx;
		border-radius: 8rpx;
		box-shadow: 0px 6rpx 12rpx rgba(0, 0, 0, 0.16);
		.inputBox{
			flex: 1;
			padding-right: 30rpx;
			.inputRow{
				height: 80rpx;
				display: flex;
				align-items: center;
				font-size: 32rpx;
				padding-left: 20rpx;
				.label{
					color: #191919;
					margin-right: 30rpx;
				}
			}
			.input{
				
			}
			.emty{
				color: #c0c4cc;
			}
			.val{
				
			}
		}
		.btnBox{
			display: flex;
			flex-direction: column;
			padding: 10rpx 0;
			.reset{
				margin-top: 20rpx;
				border: 1px solid #f1f1f1;
				background: #fff !important;
				color: #353535 !important;
			}
			.btn{
				padding: 0 30rpx;
				// width: 110rpx;
				height: 60rpx;
				display: flex;
				align-items: center;
				justify-content: center;
				background: #1890ff;
				border-radius: 8rpx;
				color: #fff;
			}
		}
	}
	
	.boxItem{
			background-color: #fff;
			margin: 20rpx;
			border-radius: 8rpx;
			padding: 10rpx;
			box-shadow: 0px 0px 20rpx 0px rgba(102,102,102,0.15);
			.row{
				margin: 10rpx;
				display: flex;
				.item{
					// padding-left: 10rpx;
					// width: 50%;
					flex: 1;
					display: flex;
				}
				.label{
					color: #969696;
				}
				.val{
					color: #353535;
					font-size: 32rpx;
				}
				.btn{
						padding: 0 30rpx;
						// width: 120rpx;
						height: 60rpx;
						display: flex;
						align-items: center;
						justify-content: center;
						background: #1890ff;
						border-radius: 8rpx;
						color: #fff;
						margin-right: 10rpx;
				}
			}
		}
		
}
</style>
